export default {
    // 外部点击事件
    mounted(el: HTMLElement, binding:any , vnode: any) {
        vnode.__vueClickOutside__ = (e:any)=>{
            if (e.target === el || el.contains(e.target as Element)) {
                return false
            } else {
                // 触发回调函数
                binding.value()
            }
        }
        document.addEventListener('click', e=> vnode?.__vueClickOutside__(e))
    },
    // dom销毁删除
    unmounted(_el: HTMLElement, _binding:any , _vnode: any) {
        delete _vnode.__vueClickOutside__
    }
}